using System;
using System.Runtime.InteropServices;
using System.Text;

namespace OpenNETCF.Compression
{
    [StructLayout(LayoutKind.Sequential)]
    unsafe internal struct z_stream
    {
        public byte* next_in;  /* next input byte */
        public int avail_in;  /* number of bytes available at next_in */
        public int total_in;  /* total nb of input bytes read so far */

        public byte* next_out; /* next output byte should be put there */
        public int avail_out; /* remaining free space at next_out */
        public int total_out; /* total nb of bytes output so far */

        //[MarshalAs(UnmanagedType.LPStr)]
        public IntPtr msg;      /* last error message, NULL if no error */
        IntPtr state; /* not visible by applications */

        public IntPtr zalloc;  /* used to allocate the internal state */
        public IntPtr zfree;   /* used to free the internal state */
        public IntPtr opaque;  /* private data object passed to zalloc and zfree */

        public int data_type;  /* best guess about the data type: binary or text */
        public int adler;      /* adler32 value of the uncompressed data */
        public uint reserved;   /* reserved for future use */

        public string Message
        {
            get
            {
                if (msg == IntPtr.Zero)
                    return "";
                else
                    return Marshal.PtrToStringUni(msg);
            }
        }
    }
}
